<?php
/**
 * Created by PhpStorm.
 * User: lee
 * Date: 2015/6/25
 * Time: 16:13
 */
header("Content-type: text/html; charset=utf-8");

echo "time() ", time(). "<br>";

echo "今天是 " . date("Y/m/d") . "<br>";
echo "今天是 " . date("Y.m.d") . "<br>";
echo "今天是 " . date("Y-m-d") . "<br>";
echo "今天是 " . date("l") . "<br>";
# 使用 date() 函数在您的网站上自动更新版本年份：
echo "© 2010-" . date("Y") . "<br>";

echo "现在时间是 " . date("h:i:s a") . "<br>";
// 设置时区
date_default_timezone_set("Asia/Shanghai");
echo "当前时间是 " . date("h:i:s a") . "<br>";

// mktime(hour,minute,second,month,day,year)
$d = mktime(9, 12, 31, 6, 10, 2015);
echo "创建日期是 " . date("Y-m-d h:i:s a", $d);
echo '<br>';

// strtotime(time,now)
$d=strtotime("10:38pm April 15 2015");
echo "创建日期是 " . date("Y-m-d h:i:s a", $d);
echo '<br>';

$d=strtotime("tomorrow");
echo date("Y-m-d h:i:s a", $d) . "<br>";

$d=strtotime("next Saturday");
echo date("Y-m-d h:i:s a", $d) . "<br>";

$d=strtotime("+3 Months");
echo date("Y-m-d h:i:s a", $d) . "<br>";


// 周六的日期：
$startdate = strtotime("Saturday");
$enddate = strtotime("+4 weeks",$startdate);

while ($startdate < $enddate) {
    echo date("M d", $startdate),"<br>";
    $startdate = strtotime("+1 week", $startdate);
}

// 12月31日之前的天数：
$d1=strtotime("December 31");
$d2=ceil(($d1-time())/60/60/24);
echo "距离十二月三十一日还有：" . $d2 ." 天。";
